package com.zjm.servlet.servlet05_config_context;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author ZJM
 * @date 2024/4/11 21:50
 * ServletConfig类的三大作用
 */
public class ServletConfigTestServlet implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        //ServletConfig类的三大作用
        //1.获取Servlet的名称
        System.out.println("获取Servlet的名称:"+servletConfig.getServletName());
        //2.获取初始化参数
        System.out.println("获取初始化参数:"+servletConfig.getInitParameter("username"));
        System.out.println("获取初始化参数:"+servletConfig.getInitParameter("password"));
        //3.获取ServletContext对象
        System.out.println("获取ServletContext对象:"+servletConfig.getServletContext());
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
